<template>
    <div>
        <a href="Add">添加</a>
        <a href="Lists">康复理疗显示</a>
        食谱标题:
        <input type="text" v-model="cha.name">
        分类:
        <select v-model="cha.xia">
            <option value="0">请选择</option>
            <option v-for="a in datas":value="a.hoteId">{{a.hoteName}}</option>
        </select>
        <input type="button" value="查询" @click="getdate">
       <table class="table">
          <thead>
              <tr>
                <td>食谱标题</td>
                <td>分类</td>
                <td>标签</td>
                <td>分享</td>
                <td>收藏</td>
                <td>状态</td>
                <td>更新人</td>
                <td>最后更新时间</td>
              </tr>
          </thead>
          <tbody>
            <tr v-for="a in date">
                <td>{{a.userName}}</td>
                <td>{{a.hoteId==1?'午餐':'晚餐'}}</td>
                <td>{{a.userBao}}</td>
                <td>{{a.userFen}}</td>
                <td>{{a.userSho}}</td>
                <td>{{a.userStart==1?'已发布':'未发布'}}</td>
                <td>{{a.userGeng}}</td>
                <td>{{moment(a.userTime).format("yyyy-MM-DD")}}</td>
              </tr>
          </tbody>
       </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import moment from 'moment';
import { ref , onMounted } from 'vue';
import { useRouter } from 'vue-router';

onMounted(()=>{
    getdate()
    xia()
})

const date = ref([ {
    "userId": 1,
    "hoteId": 1,
    "userName": "虾仁蒸蛋",
    "userBao": "低盐",
    "userFen": "100",
    "userSho": "35",
    "userStart": 1,
    "userGeng": "张三",
    "userTime": "2025-05-05T00:00:00"
  },])

const cha = ref({
    name : '',
    xia : 0
})

const datas = ref([{
    "hoteId": 1,
    "hoteName": "午餐"
  },])

const xia=()=>{
    axios.get("/api/Hote/Show").then(res=>{
        datas.value = res.data;
    })
}

const getdate=()=>{
    axios.get("/api/User/GetAllAsync",{params:cha.value}).then(res=>{
       date.value = res.data;
    })
}



</script>

<style scoped>

</style>